Repository navigation
emu: 客体时钟源一直用 TSC(tsc=nowatchdog) - #187
Merged
Merged
Conversation
After hours of running, the guest clocksource watchdog can give up on the TSC when HPET reads are slow three times in a row, leaving the emulated HPET as the only clock; every clock read then exits to the host and games drop to a few fps until the next cold boot. Pass tsc=nowatchdog on Windows so the watchdog no longer checks the TSC; the boot-time TSC sync check still runs. Refs ModAVD/ModAVD#110
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs ModAVD/ModAVD#110
问题
一台连续开了约 14 小时的实例(明日方舟 + MAA)突然变得很卡:游戏从 55–60 fps 掉到约 5 fps,而且一直卡到下次冷启动。
现场采样:
UnityGfxDeviceWorker占满一个核,其中约 90% 是内核态;simpleperf 里read_hpet占 72%,goldfish_address_space的as_ioctl占 14%。tsc换成了hpet。内核日志:这正好是 #110 列出的第三种原因:运行中看门狗读 hpet 太慢。WHPX 不给客体 kvm-clock,tsc 一停用就只剩 QEMU 模拟的 hpet,之后每次读时钟都要退出到宿主。看门狗用 hpet 校验 tsc,主机一忙,读一次 hpet 就可能超过门限,连续三次超时就会停用 tsc。那次开机的 14 小时里,客体记了 78 次 hpet 读得慢,第 13.8 小时连续三次没过。所以开得越久,越早会碰上。
客体 CPU 报了
constant_tsc和nonstop_tsc,但没有tsc_adjust。6.1 内核要三个都有才会自动让 TSC 免检,所以看门狗一直在检查 TSC。改动
Windows 上给客体内核加
tsc=nowatchdog(通过-qemu -append,模拟器会把它合并进内核命令行,不会替换原有参数)。tsc=reliable:那个连同步检查也一起跳过。以前在没修 TSC 的模拟器上用过它,system_server读到时间倒退后崩溃了。测试
go test ./internal/emu/...通过;TestBuildLaunchArgs两张参考表都加上了-append tsc=nowatchdog。TestBuildLaunchArgs失败,恢复后通过。/proc/cmdline里有tsc=nowatchdog,原有参数都还在,时钟源是tsc;开明日方舟跑到主界面,没有新的崩溃(只有一直都有的com.google.android.bluetoothSIGABRT),关机正常。